﻿using System;
using System.Collections.Generic;
using System.Linq;
using CoreShop.Library;
using CoreShop.Model;
using SqlSugar;
using Yitter.IdGenerator;
using SqlSugar.Extensions;

namespace CoreShop.Services
{
    public class ServiceUnits
    {
        /// <summary>
        /// 根据限制价
        /// </summary>
        public static decimal GetLimitPrice(corecmsfoodordering ordering,decimal heValue,ref decimal rowDiscount)
        {
            decimal dNewPrice = heValue;
            if (heValue < ordering.minPrice)
            {
                dNewPrice = ordering.minPrice;
                if (ordering.price != 0) rowDiscount = dNewPrice / ordering.price;
            }
            if ((dNewPrice > ordering.maxPrice) && (ordering.maxPrice > 0))
            {
                dNewPrice = ordering.maxPrice;
                if (ordering.price != 0) rowDiscount = dNewPrice / ordering.price;
            }
            return dNewPrice;
        }
    }
}
